package com.ruoyi.web.controller.base;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.base.domain.BaseLake;
import com.ruoyi.base.service.IBaseLakeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 湖库信息Controller
 * 
 * @author ruoyi
 * @date 2025-07-27
 */
@RestController
@RequestMapping("/base/lake")
public class BaseLakeController extends BaseController
{
    @Autowired
    private IBaseLakeService baseLakeService;

    /**
     * 查询湖库信息列表
     */
//    @PreAuthorize("@ss.hasPermi('base:lake:list')")
    @GetMapping("/list")
    public TableDataInfo list(BaseLake baseLake)
    {
        startPage();
        List<BaseLake> list = baseLakeService.selectBaseLakeList(baseLake);
        return getDataTable(list);
    }

    /**
     * 导出湖库信息列表
     */
//    @PreAuthorize("@ss.hasPermi('base:lake:export')")
//    @Log(title = "湖库信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BaseLake baseLake)
    {
        List<BaseLake> list = baseLakeService.selectBaseLakeList(baseLake);
        ExcelUtil<BaseLake> util = new ExcelUtil<BaseLake>(BaseLake.class);
        util.exportExcel(response, list, "湖库信息数据");
    }

    /**
     * 获取湖库信息详细信息
     */
//    @PreAuthorize("@ss.hasPermi('base:lake:query')")
    @GetMapping(value = "/getinfo/{ID}")
    public AjaxResult getInfo(@PathVariable("ID") String ID)
    {
        return success(baseLakeService.selectBaseLakeByID(ID));
    }

    /**
     * 新增湖库信息
     */
//    @PreAuthorize("@ss.hasPermi('base:lake:add')")
//    @Log(title = "湖库信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody BaseLake baseLake)
    {
        return toAjax(baseLakeService.insertBaseLake(baseLake));
    }

    /**
     * 修改湖库信息
     */
//    @PreAuthorize("@ss.hasPermi('base:lake:edit')")
//    @Log(title = "湖库信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody BaseLake baseLake)
    {
        return toAjax(baseLakeService.updateBaseLake(baseLake));
    }

    /**
     * 删除湖库信息
     */
//    @PreAuthorize("@ss.hasPermi('base:lake:remove')")
//    @Log(title = "湖库信息", businessType = BusinessType.DELETE)
	@GetMapping("/remove/{IDs}")
    public AjaxResult remove(@PathVariable String[] IDs)
    {
        return toAjax(baseLakeService.deleteBaseLakeByIDs(IDs));
    }
}
